import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/authredirect', component: () => import('@/views/login/authredirect'), hidden: true },
  { path: '/404', component: () => import('@/views/errorPage/404'), hidden: true },
  { path: '/401', component: () => import('@/views/errorPage/401'), hidden: true },
  {
    path: '/components',
    component: Layout,
    redirect: 'noredirect',
    name: 'component-demo',
    meta: {
      title: 'components',
      icon: 'component'
    }
  },
  {
    path: '/mine',
    component: Layout,
    meta: { title: '设置', icon: 'dashboard', noCache: true }, hidden: true,
    children: [
      {
        path: 'password',
        name: '修改密码',
        meta: { title: '修改密码', icon: 'guide', noCache: true },
        component: () => import('@/views/mine/password'), hidden: true
      },
      {
        path: 'userInfo',
        name: '个人信息',
        meta: { title: '个人信息', icon: 'guide', noCache: true },
        component: () => import('@/views/mine/userInfo'), hidden: true
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // 先是管理员
  {
    path: '/',
    component: Layout,
    meta: { title: '控制台', icon: 'guide', noCache: true },
    children: [{
      path: '',
      component: () => import('@/views/dashboard/index'),
      name: '控制台',
      meta: { title: '控制台', icon: 'dashboard', noCache: true }
    }]
  },
  {
    path: '/dataMonitor',
    component: Layout,
    meta: { title: '数据监控', icon: 'dashboard', noCache: true },
    children: [
      {
        path: 'elecMap',
        name: '电子地图',
        meta: { title: '电子地图', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/data/elecMap')
      },
      {
        path: 'statusList',
        name: '状态列表',
        meta: { title: '状态列表', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/data/statusList')
      },
      {
        path: 'dataList',
        name: '数据列表',
        meta: { title: '数据列表', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/data/dataList')
      },
      {
        path: 'alarmList',
        name: '告警列表',
        meta: { title: '告警列表', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/data/alarmList')
      }
    ]
  },
  {
    path: '/devicesMg',
    component: Layout,
    meta: { title: '设备管理', icon: 'dashboard', noCache: true },
    children: [
      {
        path: 'devices',
        name: '设备管理',
        meta: { title: '设备管理', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/devices/devices')
      },
      {
        path: 'area',
        name: '区域管理',
        meta: { title: '区域管理', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/devices/area')
      },
      {
        path: 'remoteUnlock',
        name: '远程开锁',
        meta: { title: '远程开锁', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/devices/remoteUnlock')
      }
    ]
  },
  {
    path: '/users',
    component: Layout,
    meta: { title: '组织用户', icon: 'dashboard', noCache: true },
    children: [
      {
        path: 'department',
        name: '组织管理',
        meta: { title: '组织管理', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/user/department')
      },
      {
        path: 'users',
        name: '用户管理',
        meta: { title: '用户管理', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/user/users')
      },
      {
        path: 'roles',
        name: '角色管理',
        meta: { title: '角色管理', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/user/roles')
      }
    ]
  },
  {
    path: '/authorize',
    component: Layout,
    meta: { title: '授权管理', icon: 'dashboard', noCache: true },
    children: [
      {
        path: 'temp',
        name: '临时授权',
        meta: { title: '临时授权', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/authorize/temp')
      }
    ]
  },
  {
    path: '/sys',
    component: Layout,
    meta: { title: '系统使用', icon: 'dashboard', noCache: true },
    children: [
      {
        path: 'operLog',
        name: '操作日志',
        meta: { title: '操作日志', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/sys/operLog')
      }
    ]
  },
  {
    path: '/analysis',
    component: Layout,
    meta: { title: '统计分析', icon: 'dashboard', noCache: true },
    children: [
      {
        path: '/dashboard2/analysis',
        name: '开关锁历史记录',
        meta: { title: '开关锁历', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/analysis/lockLog')
      },
      {
        path: '/dashboard2/analysis',
        name: '告警历史统计',
        meta: { title: '告警历史', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/analysis/alarmLog')
      },
      {
        path: '/dashboard2/analysis',
        name: '区域设备数量统计',
        meta: { title: '区域设备', icon: 'guide', noCache: true },
        component: () => import('@/nb-ui/analysis/areaDevice')
      }
    ]
  },
  // {
  //   path: '/experiment',
  //   component: Layout,
  //   meta: { title: '实验室管理', icon: 'guide', noCache: true },
  //   children: [{
  //     path: 'index',
  //     component: () => import('@/views/labExperiment/index'),
  //     name: '实验室管理',
  //     meta: { title: '实验室管理', icon: 'guide', noCache: true }
  //   }, {
  //     path: 'sort',
  //     component: () => import('@/views/labExperiment/sort'),
  //     name: '实验类型',
  //     meta: { title: '实验类型', icon: 'dashboard', noCache: true }
  //   }]
  // },
  // {
  //   path: '/lab',
  //   component: Layout,
  //   redirect: '/lab/info',
  //   meta: { title: '实验室管理', icon: 'dashboard', noCache: true },
  //   children: [{
  //     path: 'info',
  //     component: () => import('@/views/lab/info/lab'),
  //     name: '基本信息',
  //     meta: { title: '基本信息', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'sort',
  //     component: () => import('@/views/lab/info/sort'),
  //     name: '实验室分类',
  //     meta: { title: '实验室分类', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'list',
  //     component: () => import('@/views/lab/appointment/labAdmin'),
  //     name: '预约情况2',
  //     meta: { title: '预约情况', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'withUser/:id(\\d+)',
  //     component: () => import('@/views/lab/appointment/userAppointment'),
  //     name: '学生预约',
  //     meta: { title: '预约详情', icon: 'dashboard', noCache: true },
  //     hidden: true
  //   }, {
  //     path: 'withTeacher/:id(\\d+)',
  //     component: () => import('@/views/lab/appointment/labAppointmentTeacher'),
  //     name: '老师排课',
  //     meta: { title: '排课详情', icon: 'dashboard', noCache: true },
  //     hidden: true
  //   }]
  // },
  // {
  //   path: '/device',
  //   component: Layout,
  //   redirect: '/device/adminPage',
  //   meta: { title: '设备管理', icon: 'dashboard', noCache: true },
  //   children: [{
  //     path: 'adminPage',
  //     component: () => import('@/views/device/adminPage'),
  //     name: '基本信息',
  //     meta: { title: '基本信息', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'adminPageDetail/:id(\\d+)',
  //     component: () => import('@/views/device/adminPageDetail'),
  //     name: '详细信息',
  //     meta: { title: '详细信息', icon: 'dashboard', noCache: true },
  //     hidden: true
  //   }, {
  //     path: 'deviceType',
  //     component: () => import('@/views/device/deviceType'),
  //     name: '类型管理',
  //     meta: { title: '类型管理', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'deviceApartment',
  //     component: () => import('@/views/device/deviceApartment'),
  //     name: '部门管理',
  //     meta: { title: '部门管理', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'deviceArea',
  //     component: () => import('@/views/device/deviceArea'),
  //     name: '存放地管理',
  //     meta: { title: '存放地管理', icon: 'dashboard', noCache: true }
  //   }]
  // },
  // {
  //   path: '/labGuard',
  //   component: Layout,
  //   meta: { title: '开放预约管理', icon: 'guide', noCache: true },
  //   children: [{
  //     path: 'index',
  //     component: () => import('@/views/studentAppoint/index'),
  //     name: '可预约列表',
  //     meta: { title: '可预约列表', icon: 'guide', noCache: true }
  //   }, {
  //     path: 'list',
  //     component: () => import('@/views/lab/guard/list'),
  //     name: '实时监控',
  //     meta: { title: '实时监控', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'live/:id(\\d+)',
  //     component: () => import('@/views/lab/guard/live'),
  //     name: '实时直播',
  //     meta: { title: '实时直播', icon: 'dashboard', noCache: true },
  //     hidden: true
  //   }]
  // },

  // {
  //   path: '/labAndExperiment',
  //   component: Layout,
  //   redirect: '/labAndExperiment/myCourseSchedule',
  //   meta: { title: '预约记录', icon: 'dashboard', noCache: true },
  //   children: [{
  //     path: 'myCourseSchedule',
  //     component: () => import('@/views/labAndExperiment/myCourseSchedule'),
  //     name: '我的排课',
  //     meta: { title: '我的排课', icon: 'guide', noCache: true }
  //   }, {
  //     path: 'myAppointments',
  //     component: () => import('@/views/labAndExperiment/myAppointments'),
  //     name: '我的预约',
  //     meta: { title: '我的预约', icon: 'guide', noCache: true }
  //   }]
  // },
  // {
  //   path: '/content',
  //   component: Layout,
  //   redirect: '/content/index',
  //   meta: { title: '门户内容管理', icon: 'guide', noCache: true },
  //   children: [{
  //     path: 'index',
  //     component: () => import('@/views/content/index'),
  //     name: '内容管理',
  //     meta: { title: '内容管理', icon: 'guide', noCache: true }
  //   }, {
  //     path: 'column',
  //     component: () => import('@/views/column/index'),
  //     name: '栏目管理',
  //     meta: { title: '栏目管理', icon: 'guide', noCache: true }
  //   }]
  // },
  // {
  //   path: '/sys',
  //   component: Layout,
  //   redirect: '/sys/terms',
  //   meta: { title: '基础信息管理', icon: 'guide', noCache: true },
  //   children: [{
  //     path: 'terms',
  //     component: () => import('@/views/sys/terms'),
  //     name: '学期管理',
  //     meta: { title: '学期管理', icon: 'guide', noCache: true }
  //   }, {
  //     path: 'timeSlots',
  //     component: () => import('@/views/sys/timeSlots'),
  //     name: '时间段',
  //     meta: { title: '时间段', icon: 'guide', noCache: true }
  //   }, {
  //     path: 'calendars',
  //     component: () => import('@/views/test/index'),
  //     name: '开放日历',
  //     meta: { title: '开放日历', icon: 'guide', noCache: true }
  //   }]
  // },
  // { // 测试页面，不在正常逻辑中，可删除
  //   path: '/test',
  //   component: Layout,
  //   redirect: '/test/index',
  //   children: [{
  //     path: 'index',
  //     component: () => import('@/views/test/index'),
  //     meta: { title: '管理员————教师', icon: 'guide', noCache: true }
  //   }]
  // },
  // {
  //   path: '/teacherPlan',
  //   component: Layout,
  //   redirect: '/teacherPlan/index',
  //   meta: { title: '教师排课', icon: 'dashboard', noCache: true },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/teacherPlan/index'),
  //       name: '指定排课计划',
  //       meta: { title: '指定排课计划', icon: 'guide', noCache: true }
  //     }, {
  //       path: 'applyExperiment',
  //       component: () => import('@/views/teacherPlan/applyExperiment'),
  //       name: '实验申请及查看',
  //       meta: { title: '实验申请及查看', icon: 'guide', noCache: true }
  //     }, {
  //       path: 'list',
  //       component: () => import('@/views/teacherPlan/list'),
  //       name: '排课计划列表',
  //       meta: { title: '排课计划列表', icon: 'guide', noCache: true }
  //     }, {
  //       path: 'course/:id',
  //       component: () => import('@/views/teacherPlan/course'),
  //       name: '课程实验',
  //       meta: { title: '课程实验', icon: 'guide', noCache: true },
  //       hidden: true
  //     }
  //   ]
  // },
  // { // 测试页面，不在正常逻辑中，可删除
  //   path: '/test',
  //   component: Layout,
  //   redirect: '/test/index',
  //   children: [{
  //     path: 'index',
  //     component: () => import('@/views/test/index'),
  //     meta: { title: '教师————学生', icon: 'guide', noCache: true }
  //   }]
  // }, {
  //   path: '/studentAppoint',
  //   component: Layout,
  //   redirect: '/studentAppoint/index',
  //   meta: { title: '学生预约', icon: 'dashboard', noCache: true },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/studentAppoint/index'),
  //       name: '可预约列表',
  //       meta: { title: '可预约列表', icon: 'guide', noCache: true }
  //     }, {
  //       path: 'appointments',
  //       component: () => import('@/views/studentAppoint/appointList'),
  //       name: '个人预约列表',
  //       meta: { title: '我的预约', icon: 'guide', noCache: true }
  //     }, {
  //       path: 'appointmentTasks',
  //       component: () => import('@/views/studentAppoint/appointList'),
  //       name: '个人预约列表',
  //       meta: { title: '实验任务', icon: 'guide', noCache: true }
  //     }, {
  //       path: 'infor/:id/:typeId',
  //       component: () => import('@/views/studentAppoint/appointInfor'),
  //       name: '填写预约信息',
  //       meta: { title: '填写预约信息', icon: 'guide', noCache: true },
  //       hidden: true
  //     }, {
  //       path: 'exInfor/:id',
  //       component: () => import('@/views/studentAppoint/experimentInfor'),
  //       name: '提交实验报告',
  //       meta: { title: '提交实验报告', icon: 'guide', noCache: true },
  //       hidden: true
  //     }
  //   ]
  // },
  // {
  //   path: '/appointment',
  //   component: Layout,
  //   redirect: '/appointmentAdmin/experiment',
  //   children: [{
  //     path: 'experiment',
  //     component: () => import('@/views/lab/appointment/experiment'),
  //     name: '实验列表',
  //     meta: { title: '实验预约', icon: 'dashboard', noCache: true }
  //   }, {
  //     path: 'experiment/:id(\\d+)',
  //     component: () => import('@/views/lab/appointment/lab'),
  //     name: '预约情况',
  //     meta: { title: '预约情况', icon: 'dashboard', noCache: true },
  //     hidden: true
  //   }]
  // },
  { path: '*', redirect: '/404', hidden: true }
]
